!(function () {
    console.log('bundle');
    BI.config("dec.constant.management.navigation", function (items) {
        items.push({
            value: "customLoginPage", // 地址栏显示的hash值
            id: "custom-login-page", // id
            text: BI.i18nText("Fine-plugin-CustomLoginPage-custom-login-menu"), // 文字
            cardType: "custom-login-page-shortcut", // 组件的shortcut,适用于用fineui开发的页面.
            cls: "fr-logo-font" // 图标类名
        });
        return items;
    });
    var config = {};
    Dec.reqGet("/url/getConfig", "{}", function (res) {
        if (res.success) {
            config = JSON.parse(res.data);
            console.log("getConfig", config);
            if (!config) {
                config = {};
            }
        }
    })

    var optionLayout = BI.inherit(BI.Widget, {
        props: {
            baseCls: "custom-page-option",
            iconCls: "",
            watermark: "",
            inputType: "text",
            value: ""
        },

        render: function () {
            var self = this;
            return {
                type: "bi.vertical",
                cls: "bi-border",
                items: [
                    {
                        type: "bi.vertical_adapt",
                        height: 36,
                        items: [
                            {
                                type: "bi.button",
                                text: BI.i18nText("Fine-plugin-CustomLoginPage-save"),
                                level: "common",
                                lgap: 10,
                                width: 40,
                                handler: function () {
                                    console.log('config');
                                    config.userPlaceholder = self.userPlaceholder.editor.getLastValidValue();
                                    config.pswPlaceholder = self.pswPlaceholder.editor.getLastValidValue();
                                    config.loginLeft = parseInt(self.loginLeft.editor.getLastValidValue());
                                    config.loginTop = parseInt(self.loginTop.editor.getLastValidValue());
                                    config.customText = (self.customText.editor.getLastValidValue());
                                    config.textSize = parseInt(self.textSize.editor.getLastValidValue());
                                    config.textLeft = parseInt(self.textLeft.editor.getLastValidValue());
                                    config.textTop = parseInt(self.textTop.editor.getLastValidValue());
                                    config.textColor = (self.textColor.combo.getValue());
                                    config.imageLeft = parseInt(self.imageLeft.editor.getLastValidValue());
                                    config.imageTop = parseInt(self.imageTop.editor.getLastValidValue());
                                    config.imageWidth = parseInt(self.imageWidth.editor.getLastValidValue());
                                    config.imageHeight = parseInt(self.imageHeight.editor.getLastValidValue());
                                    console.log('config', config);
                                    Dec.reqPost("/url/saveConfig", config, function (res) {
                                        if (res.success) {

                                        }
                                    })
                                }
                            }
                        ]
                    },
                    {
                        type: "bi.vertical_adapt",
                        height: 36,
                        items: [
                            {
                                type: "bi.label",
                                baseCls: "dec-font-weight-bold",
                                textAlign: "right",
                                text: BI.i18nText("Fine-plugin-CustomLoginPage-userPlaceholder"),//"用户名占位显示：",
                                width: 100
                            }, {
                                type: "bi.text_editor",
                                watermark: BI.i18nText("Fine-plugin-CustomLoginPage-setuserPlaceholder"),//"设置用户名输入框占位符",
                                allowBlank: false,
                                errorText: BI.i18nText("Dec-Error_Null"),
                                width: 300,
                                ref: function (_ref) {
                                    self.userPlaceholder = _ref;
                                },
                                value: config.userPlaceholder ? config.userPlaceholder : "",
                            }
                        ]
                    },
                    {
                        type: "bi.vertical_adapt",
                        height: 36,
                        items: [
                            {
                                type: "bi.label",
                                baseCls: "dec-font-weight-bold",
                                textAlign: "right",
                                text: BI.i18nText("Fine-plugin-CustomLoginPage-pswPlaceholder"),//"密码占位显示：",
                                width: 100
                            }, {
                                type: "bi.text_editor",
                                watermark: BI.i18nText("Fine-plugin-CustomLoginPage-setpswPlaceholder"),//"设置密码输入框占位符",
                                allowBlank: false,
                                errorText: BI.i18nText("Dec-Error_Null"),
                                width: 300,
                                ref: function (_ref) {
                                    self.pswPlaceholder = _ref;
                                },
                                value: config.pswPlaceholder ? config.pswPlaceholder : "",
                            }
                        ]
                    },
                    {
                        type: "bi.vertical_adapt",
                        height: 36,
                        items: [
                            {
                                type: "bi.label",
                                baseCls: "dec-font-weight-bold",
                                textAlign: "right",
                                text: BI.i18nText("Fine-plugin-CustomLoginPage-loginPos"),//"登录框位置：",
                                width: 100
                            },
                            {
                                type: "bi.label",
                                textAlign: "right",
                                text: BI.i18nText("Fine-plugin-CustomLoginPage-left"),//"左：",
                                width: 60
                            },
                            {
                                type: "bi.text_editor",
                                watermark: BI.i18nText("Fine-plugin-CustomLoginPage-posLeft"),//"距离左边界的距离",
                                allowBlank: false,
                                errorText: BI.i18nText("Dec-Error_Null"),
                                width: 60,
                                validationChecker: function (v) {
                                    if (isNaN(v)) {
                                        return false;
                                    }
                                    return true;
                                },
                                ref: function (_ref) {
                                    self.loginLeft = _ref;
                                },
                                value: config.loginLeft ? config.loginLeft : 0,
                            },
                            {
                                type: "bi.label",
                                textAlign: "right",
                                text: BI.i18nText("Fine-plugin-CustomLoginPage-top"),//"上：",
                                width: 60
                            },
                            {
                                type: "bi.text_editor",
                                watermark: BI.i18nText("Fine-plugin-CustomLoginPage-posTop"),//"距离上边界的距离",
                                allowBlank: false,
                                errorText: BI.i18nText("Dec-Error_Null"),
                                width: 60,
                                validationChecker: function (v) {
                                    if (isNaN(v)) {
                                        return false;
                                    }
                                    return true;
                                },
                                ref: function (_ref) {
                                    self.loginTop = _ref;
                                },
                                value: config.loginTop ? config.loginTop : 0,
                            }
                        ]
                    },
                    {
                        type: "bi.vertical_adapt",
                        height: 36,
                        items: [
                            {
                                type: "bi.label",
                                baseCls: "dec-font-weight-bold",
                                textAlign: "right",
                                text: BI.i18nText("Fine-plugin-CustomLoginPage-customText"),//"自定义文字：",
                                width: 100
                            },
                            {
                                type: "bi.text_editor",
                                allowBlank: true,
                                width: 120,
                                ref: function (_ref) {
                                    self.customText = _ref;
                                },
                                value: config.customText ? config.customText : "",
                            },
                            {
                                type: "bi.label",
                                textAlign: "right",
                                text: BI.i18nText("Fine-plugin-CustomLoginPage-fontSize"),//"字体大小：",
                                width: 60
                            },
                            {
                                type: "bi.text_editor",
                                watermark: BI.i18nText("Fine-plugin-CustomLoginPage-fontSize"),//"字体大小：",
                                allowBlank: true,
                                width: 40,
                                ref: function (_ref) {
                                    self.textSize = _ref;
                                },
                                validationChecker: function (v) {
                                    if (isNaN(v)) {
                                        return false;
                                    }
                                    return true;
                                },
                                value: config.textSize ? config.textSize : 0,
                            },
                            {
                                type: "bi.label",
                                textAlign: "right",
                                text: BI.i18nText("Fine-plugin-CustomLoginPage-fontColor"),//"字体color：",
                                width: 60
                            },
                            {
                                type: "bi.simple_color_chooser",
                                value: config.textColor ? config.textColor : 0,
                                ref: function (_ref) {
                                    self.textColor = _ref;
                                },
                                width: 24,
                                height: 24
                            },
                            {
                                type: "bi.label",
                                textAlign: "right",
                                text: BI.i18nText("Fine-plugin-CustomLoginPage-left"),//"左：",
                                width: 60
                            },
                            {
                                type: "bi.text_editor",
                                watermark: BI.i18nText("Fine-plugin-CustomLoginPage-posLeft"),//"距离左边界的距离",
                                allowBlank: false,
                                errorText: BI.i18nText("Dec-Error_Null"),
                                width: 40,
                                validationChecker: function (v) {
                                    if (isNaN(v)) {
                                        return false;
                                    }
                                    return true;
                                },
                                ref: function (_ref) {
                                    self.textLeft = _ref;
                                },
                                value: config.textLeft ? config.textLeft : 0,
                            },
                            {
                                type: "bi.label",
                                textAlign: "right",
                                text: BI.i18nText("Fine-plugin-CustomLoginPage-top"),//"上：",
                                width: 60
                            },
                            {
                                type: "bi.text_editor",
                                watermark: BI.i18nText("Fine-plugin-CustomLoginPage-posTop"),//"距离上边界的距离",
                                allowBlank: false,
                                errorText: BI.i18nText("Dec-Error_Null"),
                                width: 40,
                                validationChecker: function (v) {
                                    if (isNaN(v)) {
                                        return false;
                                    }
                                    return true;
                                },
                                ref: function (_ref) {
                                    self.textTop = _ref;
                                },
                                value: config.textTop ? config.textTop : 0,
                            },

                        ]
                    },
                    {
                        type: "bi.vertical_adapt",
                        height: 36,
                        items: [
                            {
                                type: "bi.label",
                                baseCls: "dec-font-weight-bold",
                                textAlign: "right",
                                text: BI.i18nText("Fine-plugin-CustomLoginPage-image"),//"自定义图片：",
                                width: 100
                            },
                            {
                                type: "bi.label",
                                ref: function (e) {
                                    self.upLoadFileText = e
                                },
                                text: BI.isEmpty(config.imageFilename) ? BI.i18nText("Dec-Look_No_Upload") : config.imageFilename,
                                title: function () {
                                    return BI.isEmpty(config.imageFilename) ? BI.i18nText("Dec-Look_No_Upload") : config.imageFilename
                                },
                                textAlign: "left",
                                width: 120
                            }, {
                                type: "bi.absolute",
                                width: 30,
                                height: 24,
                                items: [{
                                    el: {
                                        type: "bi.multifile_editor",
                                        $testId: "dec-file-login-logo",
                                        url: Dec.fineServletURL + "/v10/attach/upload?width=32&height=32",
                                        accept: "*.jpg;*.png;*.gif;*.bmp;*.jpeg;",
                                        listeners: [{
                                            eventName: BI.MultifileEditor.EVENT_ERROR, action: function (e) {
                                            }
                                        }, {
                                            eventName: BI.MultifileEditor.EVENT_UPLOADED, action: function (e) {
                                                var t = this.getValue();
                                                if (t[t.length - 1].errorCode) BI.Msg.toast(BI.i18nText(t[t.length - 1].errorMsg), {level: "error"}); else {
                                                    var attachId = t[t.length - 1].attach_id, filename = t[t.length - 1].filename;
                                                    config.imageId = attachId;
                                                    config.imageFilename = filename;
                                                    self.upLoadFileText.setValue(filename);
                                                }
                                            }
                                        }, {
                                            eventName: BI.MultifileEditor.EVENT_CHANGE, action: function () {
                                                this.upload()
                                            }
                                        }]
                                    }, top: 0, bottom: 0, left: 0, right: 0
                                }, {
                                    el: {type: "bi.icon_button", cls: "upload-font upload-button"},
                                    top: 0,
                                    bottom: 0,
                                    left: 0,
                                    right: 0
                                }]
                            }, {
                                type: "bi.label",
                                cls: "bi-tips",
                                text: BI.i18nText("Dec-Look_Background_Image_Upload_Tip", "100*100")
                            }

                        ]
                    },
                    {
                        type: "bi.vertical_adapt",
                        height: 36,
                        items: [
                            {
                                type: "bi.label",
                                baseCls: "dec-font-weight-bold",
                                textAlign: "right",
                                text: "",
                                width: 100
                            },
                            {
                                type: "bi.label",
                                textAlign: "right",
                                text: BI.i18nText("Fine-plugin-CustomLoginPage-width"),//"宽：",
                                width: 60
                            },
                            {
                                type: "bi.text_editor",
                                watermark: BI.i18nText("Fine-plugin-CustomLoginPage-width"),//"宽：",
                                allowBlank: false,
                                errorText: BI.i18nText("Dec-Error_Null"),
                                width: 60,
                                validationChecker: function (v) {
                                    if (isNaN(v)) {
                                        return false;
                                    }
                                    return true;
                                },
                                ref: function (_ref) {
                                    self.imageWidth = _ref;
                                },
                                value: config.imageWidth ? config.imageWidth : 0,
                            },
                            {
                                type: "bi.label",
                                textAlign: "right",
                                text: BI.i18nText("Fine-plugin-CustomLoginPage-height"),//"高：",
                                width: 60
                            },
                            {
                                type: "bi.text_editor",
                                watermark: BI.i18nText("Fine-plugin-CustomLoginPage-height"),//"高：",
                                allowBlank: false,
                                errorText: BI.i18nText("Dec-Error_Null"),
                                width: 60,
                                validationChecker: function (v) {
                                    if (isNaN(v)) {
                                        return false;
                                    }
                                    return true;
                                },
                                ref: function (_ref) {
                                    self.imageHeight = _ref;
                                },
                                value: config.imageHeight ? config.imageHeight : 0,
                            },
                            {
                                type: "bi.label",
                                textAlign: "right",
                                text: BI.i18nText("Fine-plugin-CustomLoginPage-left"),//"左：",
                                width: 60
                            },
                            {
                                type: "bi.text_editor",
                                watermark: BI.i18nText("Fine-plugin-CustomLoginPage-posLeft"),//"距离左边界的距离",
                                allowBlank: false,
                                errorText: BI.i18nText("Dec-Error_Null"),
                                width: 60,
                                validationChecker: function (v) {
                                    if (isNaN(v)) {
                                        return false;
                                    }
                                    return true;
                                },
                                ref: function (_ref) {
                                    self.imageLeft = _ref;
                                },
                                value: config.imageLeft ? config.imageLeft : 0,
                            },
                            {
                                type: "bi.label",
                                textAlign: "right",
                                text: BI.i18nText("Fine-plugin-CustomLoginPage-top"),//"上：",
                                width: 60
                            },
                            {
                                type: "bi.text_editor",
                                watermark: BI.i18nText("Fine-plugin-CustomLoginPage-posTop"),//"距离上边界的距离",
                                allowBlank: false,
                                errorText: BI.i18nText("Dec-Error_Null"),
                                width: 60,
                                validationChecker: function (v) {
                                    if (isNaN(v)) {
                                        return false;
                                    }
                                    return true;
                                },
                                ref: function (_ref) {
                                    self.imageTop = _ref;
                                },
                                value: config.imageTop ? config.imageTop : 0,
                            }


                        ]
                    },
                ]
            };
        },
    });
    BI.shortcut("custom-login-page-shortcut", optionLayout);

}());